﻿@model SKeeper.Application.ViewModels.Warehouse.WarehouseIndexViewModel
@{
    ViewBag.Title = "Index";
}

<h2>Лагер листа</h2>
@if (Model.Warehouses.Count() > 0)
{

    <div class="row">
        <div class="col-xs-12 filter">
           @using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "result", HttpMethod = "POST", Url = "/warehouse/filter" }))
           {
          
                <input type="hidden" name="CompanyId" value="@Model.CompanyId" />
                <p>
                    Дата: <input type="text" name="Date" id="datepicker">
                    Магацини:
                    <select name="WarehouseId">
                        <option value="0">Сите</option>
                        @foreach (var item in Model.Warehouses)
                        {
                            <option value="@item.Id">@item.Name</option>
                        }
                    </select>
                    <button class="btn btn-success">Филтрирај</button>
                </p>
           
           }
        </div>
    </div>
    <div class="row">
        <div id="result" class="col-xs-12">

        </div>
    </div>


    @*<div class="row">
            <div class="col-xs-12 col-sm-4">
                <div class="table table-responsive">
                    <table class="table table-bordered">
                        <tbody>
                            <tr>
                                <td>
                                    <a href="/warehouse/add">Додади магацини</a>
                                </td>
                            </tr>
                            @foreach (var item in Model.Warehouses)
                            {
                                <tr>
                                    <td>
                                        <a href="/warehouse/index/@item.Id">
                                            @item.Name
                                        </a>
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="col-xs-12 col-sm-8">
                <div class="table table-responsive">
                    <table class="table table-bordered">
                        <tbody>
                            @foreach (var item in Model.Selected.StoredItems)
                            {
                                <tr>
                                    <td>
                                        @item.Name
                                    </td>
                                    <td>
                                        @item.Quantity
                                    </td>
                                    <td>
                                        @item.Unit
                                    </td>
                                    <td>
                                        @item.Tax
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            </div>
        </div>*@
}
else
{
    <a href="/warehouse/add" class="btn btn-lg">Создај магацин</a>
}

@section scripts{
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
    <link href="~/Content/libs/jqueryUI/jquery-ui.min.css" rel="stylesheet" />
    <script src="~/Content/libs/jqueryUI/jquery-ui.min.js"></script>
    <script>
        $(function () {
            $("#datepicker").datepicker({
                maxDate: 0
            });

            $("#datepicker").datepicker('setDate', new Date());
        });
    </script>


}